WOLF core
WOLF: A Modular Estimation Framework for Robotics
XXXXXXXXXXXXXXXXXXXXXXXXvoid(0)" frameborder="0" name="MSearchResults" id="MSearchResults">
wolf::NodeStateBlocks Class Referenceabstract

Base class of the nodes having state blocks (sensors, frames, captures and landmarks) More...

#include <core/common/node_state_blocks.h>

Inheritance diagram for wolf::NodeStateBlocks:
[legend]

Public Member Functions

 NodeStateBlocks (const std::string &_category, const std::string &_type, const TypeComposite &_state_types, const VectorComposite &_state_vectors, const PriorComposite &_state_priors)
 Constructor. More...
 
virtual ~NodeStateBlocks ()
 Destructor. More...
 
virtual YAML::Node toYaml () const
 Returns a YAML node with the type, the states and their priors. More...
 
StateKeys getKeys () const
 Returns the keys of all the state blocks. More...
 
TypeComposite getStateTypes () const
 Returns the types of the states that the node can have. More...
 
bool has (const char &_sb_key) const
 Returns whether the node has a state block with this key. More...
 
bool has (const std::string &_keys) const
 Returns whether the node has state blocks with all these keys. More...
 
virtual unsigned int id () const =0
 Returns the id of the node, unique among the nodes of its category. More...
 
std::map< char, StateBlockConstPtr > getStateBlockMap () const
 Returns the state blocks by key. More...
 
std::map< char, StateBlockPtr > getStateBlockMap ()
 Returns the state blocks by key. More...
 
std::vector< StateBlockConstPtr > getStateBlockVec () const
 Returns the state blocks, ordered by key. More...
 
std::vector< StateBlockPtr > getStateBlockVec ()
 Returns the state blocks, ordered by key. More...
 
StateBlockConstPtr getP () const
 Returns the state block of key 'P' (nullptr if none) More...
 
StateBlockConstPtr getO () const
 Returns the state block of key 'O' (nullptr if none) More...
 
StateBlockPtr getP ()
 Returns the state block of key 'P' (nullptr if none) More...
 
StateBlockPtr getO ()
 Returns the state block of key 'O' (nullptr if none) More...
 
virtual void fix ()
 Fixes all the state blocks. More...
 
virtual void unfix ()
 Unfixes all the state blocks. More...
 
virtual bool isFixed () const
 Returns whether all the state blocks are fixed. More...
 
StateBlockPtr emplaceStateBlock (const char key, const std::string &_type, const Eigen::VectorXd &_vector, const bool &_fixed)
 Emplaces a state block. More...
 
StateBlockPtr emplaceStateBlockZero (const char key, const std::string &_type, const bool &_fixed)
 Emplaces a state block with zero state. More...
 
bool hasStateBlock (const StateBlockConstPtr &_sb) const
 Returns whether the state block belongs to this node. More...
 
bool setStateBlock (const char _sb_key, const StateBlockPtr &_sb)
 Replaces the existing state block of a key. More...
 
bool stateBlockKey (const StateBlockConstPtr &_sb, char &_key) const
 Gets the key of a state block of this node. Returns false if not found. More...
 
virtual StateBlockConstPtr getStateBlock (const char &_sb_key) const
 Returns the state block of a key (nullptr if none) More...
 
virtual StateBlockPtr getStateBlock (const char &_sb_key)
 Returns the state block of a key (nullptr if none) More...
 
void setProblem (ProblemPtr _problem) override
 Sets the problem (if not set yet) and notifies it of all the state blocks and prior factors. More...
 
virtual void remove (bool viral_remove_parent_without_children=false)
 Removes the node: its state blocks and the factors constraining them. More...
 
bool hasChildren () const override
 Returns whether the node has children in the Wolf tree. More...
 
void emplaceFactorStateBlock (const char &_key, const Eigen::VectorXd &_x, const Eigen::MatrixXd &_cov, unsigned int _start_idx=0)
 Emplaces an absolute (prior) factor on the state block of a key, or on a segment of it. More...
 
void emplacePriors ()
 Emplaces the prior factors (or fixes the states) according to the states' priors. More...
 
FactorBaseConstPtrSet getFactoredBySet () const
 Returns the factors constraining this node. More...
 
FactorBasePtrSet getFactoredBySet ()
 Returns the factors constraining this node. More...
 
void getFactoredBySet (FactorBaseConstPtrSet &_fac_set) const
 Adds the factors constraining this node to a set. More...
 
void getFactoredBySet (FactorBasePtrSet &_fac_set)
 Adds the factors constraining this node to a set. More...
 
FactorBaseConstPtrSet getSensoryFactorSet () const
 Returns the factors constraining this node that have a feature (not priors) More...
 
FactorBasePtrSet getSensoryFactorSet ()
 Returns the factors constraining this node that have a feature (not priors) More...
 
std::map< char, FactorBaseConstPtr > getPriorFactorMap () const
 Returns the prior factors by key. More...
 
std::map< char, FactorBasePtr > getPriorFactorMap ()
 Returns the prior factors by key. More...
 
FactorBaseConstPtr getPriorFactor (char) const
 Returns the prior factor of a key (nullptr if none) More...
 
FactorBasePtr getPriorFactor (char)
 Returns the prior factor of a key (nullptr if none) More...
 
FactorBaseConstPtrList getFactorsOf (ProcessorBaseConstPtr _processor_ptr, const std::string &type="") const
 Returns the factors constraining this node created by a processor (and of a type, if not empty) More...
 
FactorBasePtrList getFactorsOf (ProcessorBasePtr _processor_ptr, const std::string &type="")
 Returns the factors constraining this node created by a processor (and of a type, if not empty) More...
 
bool hasFactor (FactorBaseConstPtr _fac) const
 Returns whether the factor constrains this node. More...
 
VectorComposite getState (const StateKeys &_keys="") const
 Returns the state of the given keys (all if empty) More...
 
void setState (const VectorComposite &_state, const bool _notify=true)
 Sets the state of the keys in the composite. More...
 
void setState (const Eigen::VectorXd &_state, const StateKeys &_keys, const std::list< SizeEigen > &_sizes, const bool _notify=true)
 Sets the state of the given keys from a vector split in the given sizes. More...
 
void setState (const Eigen::VectorXd &_state, const StateKeys &_keys, const bool _notify=true)
 Sets the state of the given keys from a vector (the concatenation of their states) More...
 
void setState (const StateKeys &_keys, const std::list< Eigen::VectorXd > &_vectors, const bool _notify=true)
 Sets the state of the given keys from a list of vectors, one per key. More...
 
Eigen::VectorXd getStateVector (const StateKeys &_keys) const
 Returns the concatenation of the states of the given keys. More...
 
unsigned int getSize (const StateKeys &_keys="") const
 Returns the size of the states of the given keys (all if empty) More...
 
unsigned int getLocalSize (const StateKeys &_keys="") const
 Returns the local (tangent) size of the states of the given keys (all if empty) More...
 
bool getCovariance (const StateKeys &_keys, Eigen::MatrixXd &_cov) const
 Gets the covariance of the states of the given keys from the problem. Returns false if not available. More...
 
void perturb (double amplitude=0.01)
 Perturbs the non-fixed state blocks with random noise following a uniform distribution in [-amplitude, amplitude] (in the tangent space) More...
 
bool isCapture () const
 Returns whether the node is a capture. More...
 
bool isFrame () const
 Returns whether the node is a frame. More...
 
bool isLandmark () const
 Returns whether the node is a landmark. More...
 
bool isSensor () const
 Returns whether the node is a sensor. More...
 
- Public Member Functions inherited from wolf::NodeBase
 NodeBase (const std::string &_category, const std::string &_type="Undefined", const std::string &_name="")
 Constructor. More...
 
virtual ~NodeBase ()=default
 Destructor. More...
 
unsigned int nodeId () const
 Returns the node id, unique over the whole Wolf tree. More...
 
std::string getCategory () const
 Returns the category of the node. More...
 
std::string getType () const
 Returns the type (subcategory) of the node. More...
 
std::string getName () const
 Returns the name of the node. More...
 
bool isRemoving () const
 Returns whether the node is being removed. More...
 
virtual bool hasChildren () const =0
 Returns whether the node has children in the Wolf tree. More...
 
void setType (const std::string &_type)
 Sets the type (subcategory) of the node. More...
 
void setName (const std::string &_name)
 Sets the name of the node. More...
 
ProblemConstPtr getProblem () const
 Returns the problem the node belongs to. More...
 
ProblemPtr getProblem ()
 Returns the problem the node belongs to. More...
 

Protected Member Functions

virtual void removeStateBlock (const char &_sb_key)
 Removes the state block of a key (and notifies the problem) More...
 
void transform (const VectorComposite &_transformation)
 Transforms all the state blocks (to another reference frame) More...
 
void printState (bool _factored_by, bool _metric, bool _state_blocks, std::ostream &_stream, std::string _tabs) const
 Prints the state blocks and their priors. More...
 
CheckLog localCheck (bool _verbose, std::ostream &_stream, std::string _tabs) const
 Checks the consistency of the state blocks and the factors constraining them. More...
 
virtual void setProblem (ProblemPtr _prob_ptr)
 Sets the problem the node belongs to. More...
 

Additional Inherited Members

- Protected Attributes inherited from wolf::NodeBase
ProblemWPtr problem_ptr_
 Problem the node belongs to. More...
 
unsigned int node_id_
 Node id. It is unique over the whole Wolf Tree. More...
 
std::string node_category_
 Text label identifying the category of node ("SENSOR", "FEATURE", etc) More...
 
std::string node_type_
 Type or subcategory of node (derived class name: "SensorOdom2d", etc) More...
 
std::string node_name_
 
bool is_removing_
 A flag for safely removing nodes from the Wolf tree. See remove(). More...
 

Detailed Description

Base class of the nodes having state blocks (sensors, frames, captures and landmarks)

Stores the state blocks by key, their priors, and the factors constraining them.

Constructor & Destructor Documentation

◆ NodeStateBlocks()

wolf::NodeStateBlocks::NodeStateBlocks ( const std::string &  _category,
const std::string &  _type,
const TypeComposite &  _state_types,
const VectorComposite &  _state_vectors,
const PriorComposite &  _state_priors 
)

Constructor.

Parameters
_categoryTO BE HARDCODED IN THE DERIVED CLASS CONSTRUCTOR: category name (see node_base.h)
_typeTO BE HARDCODED IN THE DERIVED CLASS CONSTRUCTOR: derived type name
_state_typesComposite of types of the states that the node can have. Probably to be hardcoded in the derived class constructor.
_state_vectorsComposite of vectors of the states of the node. A 'StateBlock' for each key in '_state_vectors' will be emplaced (of the type specified in '_state_types'). Not all keys of '_state_types' are required to be specified, but all keys of '_state_vectors' should be in '_state_types'.
_state_priorsComposite of priors (initial_guess, fix or factor) of the states of the node. Not all keys of '_state_vectors' are required to be specified, but all keys of '_state_priors' should be in '_state_vectors'. If not specified, no prior is assumed, i.e. 'initial_guess'.

◆ ~NodeStateBlocks()

wolf::NodeStateBlocks::~NodeStateBlocks ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ emplaceFactorStateBlock()

void wolf::NodeStateBlocks::emplaceFactorStateBlock ( const char &  _key,
const Eigen::VectorXd &  _x,
const Eigen::MatrixXd &  _cov,
unsigned int  _start_idx = 0 
)

Emplaces an absolute (prior) factor on the state block of a key, or on a segment of it.

Parameters
_keykey of the state block to be constrained
_xprior value (its size is the size of the constrained segment)
_covcovariance
_start_idxstate segment starting index (only 0 for state blocks with local parametrization)

◆ emplacePriors()

void wolf::NodeStateBlocks::emplacePriors ( )

Emplaces the prior factors (or fixes the states) according to the states' priors.

◆ emplaceStateBlock()

StateBlockPtr wolf::NodeStateBlocks::emplaceStateBlock ( const char  key,
const std::string &  _type,
const Eigen::VectorXd &  _vector,
const bool &  _fixed 
)

Emplaces a state block.

Parameters
keyKey of the new state.
_typeType of the new state.
_vectorVector of the new state.
_fixedIf the new state is fixed (i.e. not estimated).

◆ emplaceStateBlockZero()

StateBlockPtr wolf::NodeStateBlocks::emplaceStateBlockZero ( const char  key,
const std::string &  _type,
const bool &  _fixed 
)

Emplaces a state block with zero state.

Parameters
keyKey of the new state.
_typeType of the new state.
_fixedIf the new state is fixed (i.e. not estimated).

◆ fix()

void wolf::NodeStateBlocks::fix ( )
inlinevirtual

Fixes all the state blocks.

Reimplemented in wolf::CaptureBase.

◆ getCovariance()

bool wolf::NodeStateBlocks::getCovariance ( const StateKeys &  _keys,
Eigen::MatrixXd &  _cov 
) const

Gets the covariance of the states of the given keys from the problem. Returns false if not available.

◆ getFactoredBySet() [1/4]

FactorBasePtrSet wolf::NodeStateBlocks::getFactoredBySet ( )
inline

Returns the factors constraining this node.

◆ getFactoredBySet() [2/4]

FactorBaseConstPtrSet wolf::NodeStateBlocks::getFactoredBySet ( ) const
inline

Returns the factors constraining this node.

◆ getFactoredBySet() [3/4]

void wolf::NodeStateBlocks::getFactoredBySet ( FactorBaseConstPtrSet &  _fac_set) const
inline

Adds the factors constraining this node to a set.

◆ getFactoredBySet() [4/4]

void wolf::NodeStateBlocks::getFactoredBySet ( FactorBasePtrSet &  _fac_set)
inline

Adds the factors constraining this node to a set.

◆ getFactorsOf() [1/2]

FactorBaseConstPtrList wolf::NodeStateBlocks::getFactorsOf ( ProcessorBaseConstPtr  _processor_ptr,
const std::string &  type = "" 
) const

Returns the factors constraining this node created by a processor (and of a type, if not empty)

◆ getFactorsOf() [2/2]

FactorBasePtrList wolf::NodeStateBlocks::getFactorsOf ( ProcessorBasePtr  _processor_ptr,
const std::string &  type = "" 
)

Returns the factors constraining this node created by a processor (and of a type, if not empty)

◆ getKeys()

StateKeys wolf::NodeStateBlocks::getKeys ( ) const
inline

Returns the keys of all the state blocks.

◆ getLocalSize()

unsigned int wolf::NodeStateBlocks::getLocalSize ( const StateKeys &  _keys = "") const

Returns the local (tangent) size of the states of the given keys (all if empty)

◆ getO() [1/2]

wolf::StateBlockPtr wolf::NodeStateBlocks::getO ( )
inline

Returns the state block of key 'O' (nullptr if none)

◆ getO() [2/2]

wolf::StateBlockConstPtr wolf::NodeStateBlocks::getO ( ) const
inline

Returns the state block of key 'O' (nullptr if none)

◆ getP() [1/2]

wolf::StateBlockPtr wolf::NodeStateBlocks::getP ( )
inline

Returns the state block of key 'P' (nullptr if none)

◆ getP() [2/2]

wolf::StateBlockConstPtr wolf::NodeStateBlocks::getP ( ) const
inline

Returns the state block of key 'P' (nullptr if none)

◆ getPriorFactor() [1/2]

FactorBasePtr wolf::NodeStateBlocks::getPriorFactor ( char  key)
inline

Returns the prior factor of a key (nullptr if none)

◆ getPriorFactor() [2/2]

FactorBaseConstPtr wolf::NodeStateBlocks::getPriorFactor ( char  key) const
inline

Returns the prior factor of a key (nullptr if none)

◆ getPriorFactorMap() [1/2]

std::map< char, FactorBasePtr > wolf::NodeStateBlocks::getPriorFactorMap ( )
inline

Returns the prior factors by key.

◆ getPriorFactorMap() [2/2]

std::map< char, FactorBaseConstPtr > wolf::NodeStateBlocks::getPriorFactorMap ( ) const
inline

Returns the prior factors by key.

◆ getSensoryFactorSet() [1/2]

FactorBasePtrSet wolf::NodeStateBlocks::getSensoryFactorSet ( )
inline

Returns the factors constraining this node that have a feature (not priors)

◆ getSensoryFactorSet() [2/2]

FactorBaseConstPtrSet wolf::NodeStateBlocks::getSensoryFactorSet ( ) const
inline

Returns the factors constraining this node that have a feature (not priors)

◆ getSize()

unsigned int wolf::NodeStateBlocks::getSize ( const StateKeys &  _keys = "") const

Returns the size of the states of the given keys (all if empty)

◆ getState()

VectorComposite wolf::NodeStateBlocks::getState ( const StateKeys &  _keys = "") const

Returns the state of the given keys (all if empty)

◆ getStateBlock() [1/2]

wolf::StateBlockPtr wolf::NodeStateBlocks::getStateBlock ( const char &  _sb_key)
inlinevirtual

Returns the state block of a key (nullptr if none)

Reimplemented in wolf::CaptureBase, and wolf::SensorBase.

◆ getStateBlock() [2/2]

wolf::StateBlockConstPtr wolf::NodeStateBlocks::getStateBlock ( const char &  _sb_key) const
inlinevirtual

Returns the state block of a key (nullptr if none)

Reimplemented in wolf::CaptureBase, and wolf::SensorBase.

◆ getStateBlockMap() [1/2]

std::map< char, StateBlockPtr > wolf::NodeStateBlocks::getStateBlockMap ( )
inline

Returns the state blocks by key.

◆ getStateBlockMap() [2/2]

std::map< char, StateBlockConstPtr > wolf::NodeStateBlocks::getStateBlockMap ( ) const
inline

Returns the state blocks by key.

◆ getStateBlockVec() [1/2]

std::vector< StateBlockPtr > wolf::NodeStateBlocks::getStateBlockVec ( )
inline

Returns the state blocks, ordered by key.

◆ getStateBlockVec() [2/2]

std::vector< StateBlockConstPtr > wolf::NodeStateBlocks::getStateBlockVec ( ) const
inline

Returns the state blocks, ordered by key.

◆ getStateTypes()

TypeComposite wolf::NodeStateBlocks::getStateTypes ( ) const
inline

Returns the types of the states that the node can have.

◆ getStateVector()

VectorXd wolf::NodeStateBlocks::getStateVector ( const StateKeys &  _keys) const

Returns the concatenation of the states of the given keys.

◆ has() [1/2]

bool wolf::NodeStateBlocks::has ( const char &  _sb_key) const
inline

Returns whether the node has a state block with this key.

◆ has() [2/2]

bool wolf::NodeStateBlocks::has ( const std::string &  _keys) const
inline

Returns whether the node has state blocks with all these keys.

◆ hasChildren()

bool wolf::NodeStateBlocks::hasChildren ( ) const
inlineoverridevirtual

Returns whether the node has children in the Wolf tree.

Implements wolf::NodeBase.

Reimplemented in wolf::FrameBase.

◆ hasFactor()

bool wolf::NodeStateBlocks::hasFactor ( FactorBaseConstPtr  _fac) const
inline

Returns whether the factor constrains this node.

◆ hasStateBlock()

bool wolf::NodeStateBlocks::hasStateBlock ( const StateBlockConstPtr &  _sb) const

Returns whether the state block belongs to this node.

◆ id()

virtual unsigned int wolf::NodeStateBlocks::id ( ) const
pure virtual

Returns the id of the node, unique among the nodes of its category.

Implemented in wolf::CaptureBase, wolf::FrameBase, wolf::LandmarkBase, and wolf::SensorBase.

◆ isCapture()

bool wolf::NodeStateBlocks::isCapture ( ) const
inline

Returns whether the node is a capture.

◆ isFixed()

bool wolf::NodeStateBlocks::isFixed ( ) const
virtual

Returns whether all the state blocks are fixed.

◆ isFrame()

bool wolf::NodeStateBlocks::isFrame ( ) const
inline

Returns whether the node is a frame.

◆ isLandmark()

bool wolf::NodeStateBlocks::isLandmark ( ) const
inline

Returns whether the node is a landmark.

◆ isSensor()

bool wolf::NodeStateBlocks::isSensor ( ) const
inline

Returns whether the node is a sensor.

◆ localCheck()

CheckLog wolf::NodeStateBlocks::localCheck ( bool  _verbose,
std::ostream &  _stream,
std::string  _tabs 
) const
protected

Checks the consistency of the state blocks and the factors constraining them.

◆ perturb()

void wolf::NodeStateBlocks::perturb ( double  amplitude = 0.01)

Perturbs the non-fixed state blocks with random noise following a uniform distribution in [-amplitude, amplitude] (in the tangent space)

◆ printState()

void wolf::NodeStateBlocks::printState ( bool  _factored_by,
bool  _metric,
bool  _state_blocks,
std::ostream &  _stream,
std::string  _tabs 
) const
protected

Prints the state blocks and their priors.

◆ remove()

void wolf::NodeStateBlocks::remove ( bool  viral_remove_parent_without_children = false)
virtual

Removes the node: its state blocks and the factors constraining them.

Parameters
viral_remove_parent_without_childrenif true, parent nodes left without children are removed too

Reimplemented in wolf::CaptureBase, wolf::FrameBase, and wolf::LandmarkBase.

◆ removeStateBlock()

void wolf::NodeStateBlocks::removeStateBlock ( const char &  _sb_key)
protectedvirtual

Removes the state block of a key (and notifies the problem)

◆ setProblem()

void wolf::NodeStateBlocks::setProblem ( ProblemPtr  _problem)
overridevirtual

Sets the problem (if not set yet) and notifies it of all the state blocks and prior factors.

Reimplemented from wolf::NodeBase.

Reimplemented in wolf::LandmarkBase, wolf::FrameBase, and wolf::SensorBase.

◆ setState() [1/4]

void wolf::NodeStateBlocks::setState ( const Eigen::VectorXd &  _state,
const StateKeys &  _keys,
const bool  _notify = true 
)

Sets the state of the given keys from a vector (the concatenation of their states)

◆ setState() [2/4]

void wolf::NodeStateBlocks::setState ( const Eigen::VectorXd &  _state,
const StateKeys &  _keys,
const std::list< SizeEigen > &  _sizes,
const bool  _notify = true 
)

Sets the state of the given keys from a vector split in the given sizes.

◆ setState() [3/4]

void wolf::NodeStateBlocks::setState ( const StateKeys &  _keys,
const std::list< Eigen::VectorXd > &  _vectors,
const bool  _notify = true 
)

Sets the state of the given keys from a list of vectors, one per key.

◆ setState() [4/4]

void wolf::NodeStateBlocks::setState ( const VectorComposite &  _state,
const bool  _notify = true 
)

Sets the state of the keys in the composite.

◆ setStateBlock()

bool wolf::NodeStateBlocks::setStateBlock ( const char  _sb_key,
const StateBlockPtr &  _sb 
)
inline

Replaces the existing state block of a key.

◆ stateBlockKey()

bool wolf::NodeStateBlocks::stateBlockKey ( const StateBlockConstPtr &  _sb,
char &  _key 
) const

Gets the key of a state block of this node. Returns false if not found.

◆ toYaml()

YAML::Node wolf::NodeStateBlocks::toYaml ( ) const
virtual

Returns a YAML node with the type, the states and their priors.

Reimplemented in wolf::LandmarkBase.

◆ transform()

void wolf::NodeStateBlocks::transform ( const VectorComposite &  _transformation)
protected

Transforms all the state blocks (to another reference frame)

◆ unfix()

void wolf::NodeStateBlocks::unfix ( )
inlinevirtual

Unfixes all the state blocks.

Reimplemented in wolf::CaptureBase.


The documentation for this class was generated from the following files: